var express = require('express');
var router = express.Router();

const { getSales, addSales, deleteSales, modifySales, getAllCustomersBelongToTheSales,getSaleOne,upDataOne } = require("../service/salesService");

// 获取销售员数据
router.get('/getSales', async function (req, res, next) {
    res.send(await getSales(req.query));
});


// 通过id获取该销售员数据
router.get('/getSalesById', async function (req, res, next) {
    res.send(await getSalesById(req.query));
});


// 新增销售员
router.post("/addSales", async function (req, res) {
    res.send(await addSales(req.body));
})


// 软删除销售员
router.post("/deleteSales", async function (req, res) {
    console.log(req.body, "这是后端收到的数据");
    res.send(await deleteSales(req.body));
})


// 修改销售员数据
router.post("/modifySales", async function (req, res) {
    res.send(await modifySales(req.body));
})

// 查看该销售员负责的客户列表
router.post("/getAllCustomersBelongToTheSales", async function (req, res) {
    res.send(await getAllCustomersBelongToTheSales(req.body));
})
//（新）获取销售员信息
router.post('/getSaleOne',async function(req,res){
  
        const data  = await getSaleOne(req.body)
        res.send(data)
})
//(新)修改销售信息
router.post('/upDataOne',async function(req,res){
    
    const data = await upDataOne(req.body)
    res.send(data)
})

module.exports = router;
